<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class Category extends Model
{
    protected $fillable=['name'];
    protected $table='categories';
    protected $primaryKey = 'cid';

    public static function addCategory( $name){
        $isexit = self::where('name',$name)->get();
        if($isexit ==''){
            return null;
        }else{
            $result = self::create([
                'name' => $name,
            ]);

            return $result;
        }
    }

    public static function getList(){
        $result = self::select('name','cid')->get()->toArray();
        return $result;
    }


}